<template>
  <div class="moneyDetail">
    <div class="bt_box">
      <p class="btText">总部管理员账号</p>
    </div>
    <div class="information">
      <div class="list" style="with: 100%">
        <div class="lable"><span class="import">*</span>总部管理员账号:</div>
        <el-input v-model="fromBase.account" placeholder="请输入总部管理员账号" style="width: 202px"></el-input>
      </div>
      <div class="list" style="with: 100%">
        <div class="lable">
          <span class="import">*</span>发连锁通用卡存管比例:
        </div>
        <el-input v-model="fromBase.ratio" placeholder="请输入存管比例" style="width: 202px">
          <template slot="append">%</template>
        </el-input>
      </div>
    </div>
    <div class="bt_box">
      <p class="btText">客户基本资料</p>
    </div>
    <div class="information">
      <div class="list">
        <div class="lable"><span class="import">*</span>企业名称:</div>
        <div>
          <el-input v-model="fromBase.businessLicence" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>统一社会信用代码:</div>
        <div>
          <el-input v-model="fromBase.businessLicenceNo" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable">客户类型:</div>
        <div class="txt">
          <el-select v-model="fromBase.merchantType" placeholder="请选择">
            <el-option v-for="item in options" :key="item.id" :label="item.value" :value="item.id">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>客户简称:</div>
        <div>
          <el-input v-model="fromBase.userShortName" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>企业成立日期:</div>
        <div>
          <el-date-picker v-model="fromBase.businessLicenceSdate" type="date" placeholder="选择日期" format="yyyy.MM.dd"
            value-format="yyyy.MM.dd" :clearable="false">
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>经营期限:</div>
        <div>
          <el-radio-group v-model="radio" @change="changeRadio">
            <el-radio :label="1">
              <el-date-picker v-model="qxDate" type="date" placeholder="选择日期" format="yyyy.MM.dd"
                value-format="yyyy.MM.dd" :clearable="false" :disabled="pickDisabled" @change="changeDate">
              </el-date-picker>
            </el-radio>
            <el-radio :label="2" style="margin-top: 10px">长期</el-radio>
          </el-radio-group>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人姓名:</div>
        <div>
          <el-input v-model="fromBase.legalPersonName" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人证件类型:</div>
        <div class="text">身份证</div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人身份证号:</div>
        <div>
          <el-input v-model="fromBase.legalPersonId" placeholder="请输入"></el-input>
        </div>
      </div>

      <div class="list">
        <div class="lable">
          <span class="import">*</span>法人身份证开始日期:
        </div>
        <div>
          <el-date-picker v-model="fromBase.legalPersonIdSdate" type="date" placeholder="选择日期" format="yyyy.MM.dd"
            value-format="yyyy.MM.dd" :clearable="false">
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable">
          <span class="import">*</span>法人身份证结束日期:
        </div>
        <div>
          <el-date-picker v-model="fromBase.legalPersonIdEdate" type="date" placeholder="选择日期" format="yyyy.MM.dd"
            value-format="yyyy.MM.dd" :clearable="false">
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>法人联系电话:</div>
        <div>
          <el-input v-model="fromBase.phone" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>注册地址:</div>
        <div>
          <el-input v-model="fromBase.registeredAddress" placeholder="请输入"></el-input>
        </div>
      </div>
    </div>
    <div class="bt_box">
      <p class="btText">结算账户资料</p>
    </div>
    <div class="information">
      <div class="list">
        <div class="lable"><span class="import">*</span>结算方式:</div>
        <div class="txt">
          <el-select v-model="fromBase.settleBankType" placeholder="请选择" @change="changeBankType">
            <el-option v-for="item in options2" :key="item.id" :label="item.value" :value="item.id">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>结算费率:</div>
        <div>
          <el-input v-model="fromBase.balanceAccRate" placeholder="请输入"><template slot="append">%</template></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>结算类型:</div>
        <div class="txt">
          <el-select v-model="fromBase.clearingType" placeholder="请选择">
            <el-option v-for="item in options3" :key="item.id" :label="item.value" :value="item.id">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable"><span class="import">*</span>法人姓名:</div>
        <div>
          <el-input v-model="fromBase.legalPersonName" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable"><span class="import">*</span>非法人姓名:</div>
        <div>
          <el-input v-model="fromBase.unincorporatedName" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable"><span class="import">*</span>法人身份证号:</div>
        <div>
          <el-input v-model="fromBase.legalPersonId" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable"><span class="import">*</span>非法人身份证号:</div>
        <div>
          <el-input v-model="fromBase.unincorporatedId" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable">
          <span class="import">*</span>法人身份证开始日期:
        </div>
        <div>
          <el-date-picker v-model="fromBase.legalPersonIdSdate" type="date" placeholder="选择日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          <span class="import">*</span>非法人身份证开始日期:
        </div>
        <div>
          <el-date-picker v-model="fromBase.unincorporatedIdSdate" type="date" placeholder="选择日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType != 3">
        <div class="lable">
          <span class="import">*</span>法人身份证结束日期:
        </div>
        <div>
          <el-date-picker v-model="fromBase.legalPersonIdEdate" type="date" placeholder="选择日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </div>
      </div>
      <div class="list" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          <span class="import">*</span>非法人身份证结束日期:
        </div>
        <div>
          <el-date-picker v-model="fromBase.unincorporatedIdEdate" type="date" placeholder="选择日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>结算银行卡号:</div>
        <div>
          <el-input v-model="fromBase.balanceAccCardno" placeholder="请输入"></el-input>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>开户行名称:</div>
        <div class="txt">
          <el-select v-model="fromBase.bankName" placeholder="请选择" @change="changes">
            <el-option v-for="item in bankOptionone" :key="item.id" :label="item.label" :value="item.id">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>所属支行名称:</div>
        <div class="txt">
          <el-select v-model="fromBase.openAccBankname" placeholder="请选择" @change="changesTwo">
            <el-option v-for="item in bankOptiontwo" :key="item.id" :label="item.label" :value="item.id">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="list">
        <div class="lable"><span class="import">*</span>银行预留手机号:</div>
        <div>
          <el-input v-model="fromBase.bankMobile" placeholder="请输入"></el-input>
        </div>
      </div>
    </div>
    <div class="bt_box">
      <p class="btText">资质图片</p>
    </div>
    <div class="imgBox" v-loading="allLoading" element-loading-text="上传中">
      <div class="imgList">
        <div class="lable">
          营业执照:
          <p class="watch_img" @click="handleFang(fromImg.businessLicenceImg)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(1, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.businessLicenceImg" :src="fromImg.businessLicenceImg" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 1">
        <div class="lable">
          开户许可证:
          <p class="watch_img" @click="handleFang(fromImg.licence)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(2, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.licence" :src="fromImg.licence" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          法人身份证正面:
          <p class="watch_img" @click="handleFang(fromImg.legalPersonFront)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(3, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.legalPersonFront" :src="fromImg.legalPersonFront" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          法人身份证反面:
          <p class="watch_img" @click="handleFang(fromImg.legalPersonBack)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(4, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.legalPersonBack" :src="fromImg.legalPersonBack" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          门头照:
          <p class="watch_img" @click="handleFang(fromImg.shopTop)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(5, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.shopTop" :src="fromImg.shopTop" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          室内场景照:
          <p class="watch_img" @click="handleFang(fromImg.shopInterior)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(6, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.shopInterior" :src="fromImg.shopInterior" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList">
        <div class="lable">
          收银台照:
          <p class="watch_img" @click="handleFang(fromImg.shopCashierDesk)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(7, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.shopCashierDesk" :src="fromImg.shopCashierDesk" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType != 1">
        <div class="lable">
          结算银行卡正面:
          <p class="watch_img" @click="handleFang(fromImg.bankCardFront)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(8, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.bankCardFront" :src="fromImg.bankCardFront" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType != 1">
        <div class="lable">
          结算银行卡反面:
          <p class="watch_img" @click="handleFang(fromImg.bankCardBack)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(9, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.bankCardBack" :src="fromImg.bankCardBack" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          非法人身份证正面:
          <p class="watch_img" @click="handleFang(fromImg.unLegalPersonFront)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(10, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.unLegalPersonFront" :src="fromImg.unLegalPersonFront" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          非法人身份证反面:
          <p class="watch_img" @click="handleFang(fromImg.unLegalPersonBack)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(11, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.unLegalPersonBack" :src="fromImg.unLegalPersonBack" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <div class="imgList" v-if="fromBase.settleBankType == 3">
        <div class="lable">
          法人持授权书正面照:
          <p class="watch_img" @click="handleFang(fromImg.handAuthorization)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(12, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.handAuthorization" :src="fromImg.handAuthorization" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
      <!-- <div class="imgList">
        <div class="lable">
          法人手持身份证合照:
          <p
            class="watch_img"
            @click="handleFang(fromBase.handIdCard)"
          >
            查看图片
          </p>
        </div>
        <el-upload
          class="avatar-uploader"
          :action="action"
          :show-file-list="false"
          :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(13, response, file, fileList)
          "
          :before-upload="beforeAvatarUpload"
          :on-progress="handlePreview"
        >
          <img
            v-if="fromBase.handIdCard"
            :src="fromBase.handIdCard"
            class="img"
          />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div> -->
      <div class="imgList" v-if="fromBase.settleBankType == 1">
        <div class="lable">
          面签二联单合同:
          <p class="watch_img" @click="handleFang(fromImg.contract)">
            查看图片
          </p>
        </div>
        <el-upload class="avatar-uploader" :action="action" :show-file-list="false" :on-success="
            (response, file, fileList) =>
              handleAvatarSuccess(14, response, file, fileList)
          " :before-upload="beforeAvatarUpload" :on-progress="handlePreview">
          <img v-if="fromImg.contract" :src="fromImg.contract" class="img" />
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
        </el-upload>
      </div>
    </div>
    <img-detail-dialog v-if="ImgDetailDialog" :id="id" :imgUrl="urlData" :visible.sync="ImgDetailDialog" />
    <div class="button_box">
      <el-button style="margin: 0 10px 0 20px" @click="getPush" type="primary" :loading="buttomLoading">推送银盛开户
      </el-button>
      <el-button style="margin: 0 10px 0 20px" @click="clickDialog">已有商户号</el-button>
    </div>
    <!-- 已有商户号弹窗 -->
    <el-dialog title="已有商户号" :visible.sync="dialogFormVisible" center width="500px">
      <el-form :model="fromBase">
        <el-form-item label="第三方支付公司：" :label-width="formLabelWidth">
          <el-select v-model="fromBase.payType" placeholder="请选择">
            <el-option label="银盛" value="3"></el-option>
            <el-option label="合利宝" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="第三方商户号：" :label-width="formLabelWidth">
          <el-input v-model="thirdMerchantNo"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="getPush" :loading="buttomLoading2">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  // components
  import Loading from "@/components/Loading/index";
  import imgDetailDialog from "./components/imgDetailDialog";

  //api
  import {
    adminDict,
    getBank,
    addMerchant,
    getmerchantDetail,
    updateMerchant,
  } from "@/api/chainManagement";

  export default {
    components: {
      Loading,
      imgDetailDialog,
    },
    props: {
      visible: Boolean,
      id: String,
    },
    data() {
      return {
        dialogFormVisible: false,
        formLabelWidth: "130px",
        merchantId: "",
        allLoading: false,
        buttomLoading: false,
        buttomLoading2: false,
        action: process.env.VUE_APP_BASE_API + "/common/v1/uploadFile",
        detailDialog: false,
        data: {},
        ImgDetailDialog: false,
        options: [],
        options2: [],
        options3: [],
        value: "",
        input: "",
        typeLs: [],
        avalue: [],
        radio: 2, //经营期限选择
        pickDisabled: true, //是否禁用经营期限时间选择
        qxDate: "",
        ysimgurl: "", //二联单合同图片路径
        fromBase: {
          account: "", //管理员帐号
          businessLicence: "", //企业名称
          businessLicenceNo: "", //营业执照号码
          userShortName: "", //商户简称
          merchantType: "1", //连锁商家类型 1 企业商家 2 个体商家
          businessLicenceSdate: "", //营业执照开始日期
          businessLicenceEdate: "长期", //营业执照结束日期
          legalPersonName: "", //法人姓名
          legalPersonId: "", //法人身份证号
          legalPersonIdSdate: "", //法人身份证开始日期
          legalPersonIdEdate: "", //法人身份证到期日期
          phone: "", //法人联系电话
          registeredAddress: "", //注册地址
          settleBankType: "1", //结算方式
          unincorporatedName: "", //非法人姓名
          unincorporatedId: "", //非法人身份证号码
          unincorporatedIdSdate: "", //非法人身份证开始日期
          unincorporatedIdEdate: "", //非法人身份证到期日期
          balanceAccCardno: "", //结算账户卡号
          balanceAccRate: "0.3", //结算账户费率
          bankName: "", //开户行名称
          openAccBankname: "", //开户支行名称
          bankMobile: "", //银行预留手机号
          certType: "00", //证件类型 00 身份证
          clearingType: "", //结算类型
          // businessLicenceImg: "", //营业执照图片
          // legalPersonFront: "", //法人身份证正面
          // legalPersonBack: "", //法人身份证反面
          // bankCardFront: "", //结算银行卡正面
          // bankCardBack: "", //结算银行卡反面
          // shopTop: "", //商户门头照片
          // shopInterior: "", //内景照片
          // shopCashierDesk: "", //收银台照片
          // handIdCard: "", //手持身份证合影照片
          // contract: "", //二联单合同
          // licence: "", //开户许可证
          // handAuthorization: "", //法人/非法人手持授权书
          // settleAuthorization: "", //法人/非法人结算授权书
          // unLegalPersonFront: "", //非法人身份证正面
          // unLegalPersonBack: "", //非法人身份证反面
          payType: '-1', //支付服务商 1 合利宝 3 银盛
          // thirdMerchantNo: "", //商户号
        },
        thirdMerchantNo: "", //商户号
        fromImg: {
          businessLicenceImg: "", //营业执照图片
          legalPersonFront: "", //法人身份证正面
          legalPersonBack: "", //法人身份证反面
          bankCardFront: "", //结算银行卡正面
          bankCardBack: "", //结算银行卡反面
          shopTop: "", //商户门头照片
          shopInterior: "", //内景照片
          shopCashierDesk: "", //收银台照片
          handIdCard: "", //手持身份证合影照片
          contract: "", //二联单合同
          licence: "", //开户许可证
          handAuthorization: "", //法人/非法人手持授权书
          settleAuthorization: "", //法人/非法人结算授权书
          unLegalPersonFront: "", //非法人身份证正面
          unLegalPersonBack: "", //非法人身份证反面
        },
        bankOptionone: [], //银行
        bankOptiontwo: [], //支行
        info: {},
        status: 1, //区分推送接口
      };
    },
    computed: {},
    created() {
      this.merchantId = this.$route.query.id;
      this.info = this.$route.query;
      console.log(this.info.account);
      if (this.info.account != undefined) {
        this.fromBase = this.$route.query;
        this.status = 1;
      }
      // this.fromBase = this.info
      console.log(this.merchantId);
      this.getlinkagelist();
      this.getbankType();
      this.getclearingType();
      this.getBank();
      if (this.merchantId != 0 && this.info.account == undefined) {
        this.status = 2;
        this.getDetail();
      }
    },
    methods: {
      getlinkagelist() {
        //获取商户类型字典
        const params = {
          dictType: "merchant_type",
        };
        adminDict(params).then((res) => {
          this.options = res.result[0].dictList;
        });
      },
      getclearingType() {
        //获取结算类型字典
        const params = {
          dictType: "merchant_clearing_type",
        };
        adminDict(params).then((res) => {
          this.options3 = res.result[0].dictList;
        });
      },
      changeRadio(e) {
        //经营期限选择
        console.log(e);
        if (e == 2) {
          this.pickDisabled = true;
          this.fromBase.businessLicenceEdate = "长期";
        } else {
          this.pickDisabled = false;
          this.fromBase.businessLicenceEdate = this.qxDate;
        }
      },
      changeDate(e) {
        //经营期限日期选择
        console.log(e);
        this.fromBase.businessLicenceEdate = e;
      },
      //获取进件商户基础信息
      getDetail() {
        const id = this.merchantId;
        getmerchantDetail(id)
          .then((res) => {
            if (res.result.businessLicenceEdate == "长期") {
              this.fromBase.businessLicenceEdate = "长期";
              this.radio = 2;
              this.pickDisabled = true;
            } else {
              this.qxDate = res.result.businessLicenceEdate;
              this.pickDisabled = false;
              this.radio = 1;
              this.fromBase.businessLicenceEdate = this.qxDate;
            }
            this.fromBase = res.result;
          })
          .finally(() => {
            this.loading = false;
          });
      },
      getbankType() {
        //获取结算方式字典
        const params = {
          dictType: "manage_settle_bank_type",
        };
        adminDict(params).then((res) => {
          this.options2 = res.result[0].dictList;
        });
      },
      changeBankType(e) {
        //结算方式选择
        if (e == 3) {
          this.fromBase.legalPersonName = "";
          this.fromBase.legalPersonId = "";
          this.fromBase.legalPersonIdSdate = "";
          this.fromBase.legalPersonIdEdate = "";
        } else {
          this.fromBase.unincorporatedName = "";
          this.fromBase.unincorporatedId = "";
          this.fromBase.unincorporatedIdSdate = "";
          this.fromBase.unincorporatedIdEdate = "";
        }
      },
      getBank() {
        //获取银行信息
        const params = {};
        getBank(params).then((res) => {
          console.log(res.result);
          this.bankOptionone = res.result;
          // if (this.fromSettle.bankType != "") {
          this.bankOptionone.map((item, index) => {
            // if (this.fromSettle.bankType == item.id) {
            //   console.log(1111);
            //   this.bankOptiontwo = item.children;
            // }
            this.bankOptiontwo = item.children;
          });
          // }
          console.log(this.bankOptiontwo);
        });
      },
      changes(value) {
        //银行
        console.log(value);
        this.bankOptionone.map((item, index) => {
          if (value == item.id) {
            this.bankOptiontwo = item.children;
            this.fromBase.bankName = item.label;
          }
        });
      },
      changesTwo(id) {
        //支行选择
        this.bankOptiontwo.map((item, index) => {
          if (id == item.id) {
            // this.fromSettle.openAccBanktype = item.id;
            this.fromBase.openAccBankname = item.label;
          }
        });
      },
      handlePreview(e) {
        console.log(e);
        this.allLoading = true;
        setTimeout(() => {
          this.allLoading = false;
        }, 10000);
      },
      handleAvatarSuccess(e, res, file) {
        this.allLoading = false;
        //上传资质图片
        //   this.formInline.shopIcon = res.result.url;
        console.log(e);
        console.log(res.result);
        // this.fromBase.id = this.ysimgInfo.id;
        if (e == 1) {
          this.fromImg.businessLicenceImg = res.result.url;
        } else if (e == 2) {
          this.fromImg.licence = res.result.url;
        } else if (e == 3) {
          this.fromImg.legalPersonFront = res.result.url;
        } else if (e == 4) {
          this.fromImg.legalPersonBack = res.result.url;
        } else if (e == 5) {
          this.fromImg.shopTop = res.result.url;
        } else if (e == 6) {
          this.fromImg.shopInterior = res.result.url;
        } else if (e == 7) {
          this.fromImg.shopCashierDesk = res.result.url;
        } else if (e == 8) {
          this.fromBase.bankCardFront = res.result.url;
        } else if (e == 9) {
          this.fromImg.bankCardBack = res.result.url;
        } else if (e == 10) {
          this.fromImg.unLegalPersonFront = res.result.url;
        } else if (e == 11) {
          this.fromImg.unLegalPersonBack = res.result.url;
        } else if (e == 12) {
          this.fromImg.handAuthorization = res.result.url;
        } else if (e == 13) {
          this.fromImg.handIdCard = res.result.url;
        } else if (e == 14) {
          this.fromImg.contract = res.result.url;
        }
        console.log(this.fromImg);
      },
      //放大图片
      handleFang(url) {
        this.urlData = url;
        this.ImgDetailDialog = true;
      },
      onExceed(files, fileList) {
        this.$message.error("最多上传1张图片");
      },
      beforeAvatarUpload(file) {
        console.log(file);
        const format = ["image/jpeg", "image/jpg", "image/png"];
        const isJPG = format.some((item) => file.type === item);
        // const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isJPG) {
          this.$message.error("上传图片只能是 jpeg,jpg,png格式!");
        }
        //   if (!isLt2M) {
        //     this.$message.error("上传头像图片大小不能超过 2MB!");
        //   }
        // return isJPG && isLt2M;
        return isJPG;
      },
      clickDialog() {
        var formBase = {};
        if (
          this.fromBase.settleBankType == 1 ||
          this.fromBase.settleBankType == 2
        ) {
          let {
            unincorporatedName,
            unincorporatedId,
            unincorporatedIdEdate,
            unincorporatedIdSdate,
            ...newObject
          } = this.fromBase;
          formBase = newObject;
        } else {
          let {
            legalPersonName,
            legalPersonId,
            legalPersonIdSdate,
            legalPersonIdEdate,
            ...objects
          } = this.fromBase;
          formBase = objects;
        }
        var arr;
        if (
          (arr = Object.keys(formBase).filter((v) => !formBase[v])).length <= 0
        ) {
          //全部有值
          console.log("有值");
          this.dialogFormVisible = true;
        } else {
          console.log(arr); //[status,other]
          console.log("没有值");
          this.$message({
            message: "请完善信息",
            type: "warning",
            duration: 1500,
          });
        }
      },
      getPush() {
        var formBase = {};
        this.fromBase.account = this.fromBase.account.replace(
          /(^\s*)|(\s*$)/g,
          ""
        );
        if (
          this.fromBase.settleBankType == 1 ||
          this.fromBase.settleBankType == 2
        ) {
          let {
            unincorporatedName,
            unincorporatedId,
            unincorporatedIdEdate,
            unincorporatedIdSdate,
            ...newObject
          } = this.fromBase;
          formBase = newObject;
        } else {
          let {
            legalPersonName,
            legalPersonId,
            legalPersonIdSdate,
            legalPersonIdEdate,
            ...objects
          } = this.fromBase;
          formBase = objects;
        }
        var arr;
        if (
          (arr = Object.keys(formBase).filter((v) => !formBase[v])).length <= 0
        ) {
          //全部有值
          console.log("有值");
          if (this.status == 1) {
            this.setYspush();
          } else {
            this.updateMerchant();
          }
        } else {
          console.log(arr); //[status,other]
          console.log("没有值");
          this.$message({
            message: "请完善信息",
            type: "warning",
            duration: 1500,
          });
        }
        console.log(this.fromBase);
        // return;
        // if (this.status == 1) {
        //   this.setYspush();
        // } else {
        //   this.updateMerchant();
        // }
      },
      setYspush() {
        //推送银盛审核
        // return;
        if (this.dialogFormVisible == true) {
          if (this.thirdMerchantNo == "") {
            this.$message({
              message: "请填写第三方商户号",
              type: "error",
              duration: 1500,
            });
            return;
          }
          this.buttomLoading2 = true;
        } else {
          this.buttomLoading = true;
        }
        // this.buttomLoading = true;
        const params = {
          ...this.fromBase,
          ...this.fromImg,
          thirdMerchantNo: this.thirdMerchantNo,
        };
        addMerchant(params)
          // this.buttomLoading = true
          .then((res) => {
            this.$message({
              message: "推送成功",
              type: "success",
              duration: 1500,
            });
            this.buttomLoading = false;
            setTimeout(() => {
              this.$router.push({
                path: "/merchants/chain-customers-list",
              });
            }, 800);
          })
          .finally(() => {
            this.buttomLoading = false;
            this.buttomLoading2 = false;
          });
      },
      updateMerchant() {
        //更新信息
        if (this.dialogFormVisible == true) {
          if (this.thirdMerchantNo == "") {
            this.$message({
              message: "请填写第三方商户号",
              type: "error",
              duration: 1500,
            });
            return;
          }
          this.buttomLoading2 = true;
        } else {
          this.buttomLoading = true;
        }
        // this.buttomLoading = true;
        const params = {
          id: this.merchantId,
          ...this.fromBase,
          ...this.fromImg,
          thirdMerchantNo: this.thirdMerchantNo,
        };
        updateMerchant(params)
          .then((res) => {
            this.$message({
              message: "更新成功",
              type: "success",
              duration: 1500,
            });
            this.buttomLoading = false;
            setTimeout(() => {
              this.$router.push({
                path: "/merchants/chain-customers-list",
              });
            }, 800);
          })
          .finally(() => {
            this.buttomLoading = false;
          });
      },
    },
  };

</script>
<style lang="scss" scoped>
  @import "./style/chainCustomersAdd";

  ::v-deep.el-input--medium .el-input__inner {
    width: 202px !important;
  }

  .import {
    color: #ff4949;
  }

</style>
